package cn.knowimage.jsonmake;
//测试
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Test {
   public static JSONObject treatment_choice(String treatment_choice_scenario,String treatment_choice_ref,
                                             String treatment_choice_num,String treatment_choice_num_id){
       JSONObject treatment_choice = new JSONObject();
       treatment_choice.put("ref",treatment_choice_ref);
       JSONArray treatment_choice_num_s = JSONArray.fromObject(treatment_choice_num);
       JSONArray treatment_choice_num_id_s = JSONArray.fromObject(treatment_choice_num_id);
       int num;
       if (treatment_choice_scenario==null||"".equals(treatment_choice_scenario)){
           num = 0;
       }else{
           num = Integer.parseInt(treatment_choice_scenario);
   }
   JSONObject scenario = new JSONObject();
       scenario.put("num",num);
       int count = 0;
       for (int i = 0;i<num;i++){
            JSONArray id_ = new JSONArray();
            if (treatment_choice_num_s.get(i)==null||"".equals(treatment_choice_num_s.get(i))){

            }else {
                for (int j = 0;j<Integer.parseInt(treatment_choice_num_s.getString(i));j++){
                    id_.add(treatment_choice_num_id_s.getString(count));
                }
            }
            scenario.put(String.format("id_%d",i),id_);
       }
       treatment_choice.put("scenario",scenario);
       System.out.println(treatment_choice.toString());
       return treatment_choice;
   }

}